import { getDict } from "~/utils";
import { getAllProject } from "@/views/property-info-sys/project-manage/api/project_manage";
export default {
	data() {
		return {
			activeName: "资产变更信息",
			countys: [],
			citys: [],
			provinces: [],
			cardNum: "不动产证编号",
			// 所属项目
			projects: [],
			//数据字典
			//资产分类
			assetClassificationList: [],
			// 证件
			realEstateCardType: [],
			//使用状况
			useStatusList: [],
			//取得方式
			acquisitionMethodList: [],
			//价值类型
			valueTypeList: [],
			//产权形式
			propertyRightFormList: [],
			//权属证明
			ownershipCertificateList: [],
			//权属性质
			ownershipNatureList: [],
			//建筑结构
			buildingStructureList: [],
			assetDepreciationStatus: [],
			// 土地用途：land_uses
			landUses: [],
			// 规划用途：plan_uses
			planUses: [],
			// 处置类型
			handleType: [],
			// 证件类型
			cardTypes: []
		};
	},
	watch: {
		"formObj.cardType": {
			handler(val, oldVal) {
				if (val === "20") {
					this.cardNum = "移交协议编号";
				} else if (val === "30") {
					this.cardNum = "第三方评估机构报告编号";
				} else {
					this.cardNum = "不动产证编号";
				}
			}
		}
	},
	created() {
		// //获取所属项目
		getAllProject().then(rep => {
			let projectData = rep.data.data;
			if (projectData) {
				this.projects = projectData.map(p => {
					return { label: p.projectName, value: p.projectId };
				});
			}
		});
		// 数据字典
		// 资产分类
		this.assetClassificationList = getDict("asset-classification").map(e => {
			return {
				label: e.label,
				value: Number(e.value)
			};
		});
		//不动产证件类型
		this.realEstateCardType = getDict("real_estate_card_type");
		// 使用状况
		this.useStatusList = getDict("asset-use-status").map(e => {
			return {
				label: e.label,
				value: Number(e.value)
			};
		});
		// 取得方式
		this.acquisitionMethodList = getDict("asset-acquisition-method").map(e => {
			return {
				label: e.label,
				value: Number(e.value)
			};
		});
		// 价值类型
		this.valueTypeList = getDict("asset-value-type").map(e => {
			return {
				label: e.label,
				value: Number(e.value)
			};
		});
		//产权形式
		this.propertyRightFormList = getDict("asset-property-right-form").map(e => {
			return {
				label: e.label,
				value: Number(e.value)
			};
		});
		// 权属证明
		this.ownershipCertificateList = getDict("asset-ownership-certificate").map(
			e => {
				return {
					label: e.label,
					value: Number(e.value)
				};
			}
		);
		// 权属性质
		this.ownershipNatureList = getDict("asset-ownership-nature").map(e => {
			return {
				label: e.label,
				value: Number(e.value)
			};
		});
		// 建筑结构
		this.buildingStructureList = getDict("asset-building-structure").map(e => {
			return {
				label: e.label,
				value: Number(e.value)
			};
		});
		// 折旧状态
		this.assetDepreciationStatus = getDict("asset_depreciation_status").map(
			e => {
				return {
					label: e.label,
					value: Number(e.value)
				};
			}
		);
		// 土地用途
		this.landUses = getDict("land_uses");
		// 规划用途
		this.planUses = getDict("plan_uses");
		// 处置类型
		this.handleType = getDict("handle-type").map(e => {
			return {
				label: e.label,
				value: Number(e.value)
			};
		});
		//证件类型
		this.cardTypes = getDict("real_estate_card_type")
			.slice(0, 1)
			.map(e => {
				return {
					label: e.label,
					value: Number(e.value)
				};
			});
	},
	methods: {
		// 街道类型格式化
		streetsFormatter(row, column, cellValue) {
			let type = getDict("streets").find(p => p.value == cellValue);
			return type ? type.label : "";
		},
		// 社区格式化
		communityNamesFormatter(row, column, cellValue) {
			let type = getDict("community_names").find(p => p.value == cellValue);
			return type ? type.label : "";
		},
		//选择是否入库
		verifyChange(e) {
			if (e == "1") {
				this.whetherToStore = true;
			} else {
				this.whetherToStore = false;
			}
		}
	}
};
